package top.caoayu.base.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.caoayu.base.entity.dto.CommentCreateDTO;
import top.caoayu.base.entity.dto.CommentQueryDTO;
import top.caoayu.base.entity.vo.CommentVo;
import top.caoayu.base.service.ICommentService;
import top.caoayu.common.response.Result;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@Api(tags = "评论")
@RequestMapping("/Comments")
public class CommentController {
    @Resource
    private ICommentService commentServiceImpl;

    @ApiOperation(value = "评论列表")
    @PostMapping("/")
    public Result<Page<CommentVo>> list(@RequestBody CommentQueryDTO commentDTO) {
        return Result.success(null);
    }

    @ApiOperation(value = "新增评论")
    @PostMapping("/add")
    public Result add(@Valid @RequestBody CommentCreateDTO commentDTO) {
        return Result.success(null);
    }

    @ApiOperation(value = "编辑评论")
    @PostMapping("edit")
    public Result edit(@Valid @RequestBody CommentCreateDTO commentDTO) {
        return Result.success(null);
    }

    @ApiOperation(value = "删除评论")
    @PostMapping("/delete")
    public Result delete(@Valid @RequestBody Long id) {
        return Result.success(commentServiceImpl.getBaseMapper().deleteById(id));
    }

}
